<?php
/**
 * 视频分类模型
 * @createtime 2015-08-24 20:29
 * @author Halu
 */
namespace Admin\Model;
use Think\Model;
class VideoClassifyModel extends Model {
	
	protected $tableName = 'video_classify'; 
	
	//分类添加
	public function do_add($data){
		
		$rc = M('VideoClassify')->add($data);
		return $rc;
	}
	
	//分类名字检测
	public function check_name($name){
		$rc = M('VideoClassify')->where('name = "'.$name.'" and status != -1')->getField('id');
		return $rc;
	}
	
	//分类总量
	public function do_count(){
		
		$rc = M('VideoClassify')->where('status != -1')
						        ->count();
		return $rc;
		
	}	
	
	//分类列表
	public function do_list($where = '',$limit = '',$field="*"){
			
		$model = M('VideoClassify');
		$model->where('status != -1 '.$where.'')
			  ->order('id desc')
			  ->field($field);
	
		if(!empty($limit)){
			$model->limit($limit);
		}	
		
		$rc = $model->select();			
		return $rc;		  
	}
	
	//分类删除
	public function do_delete($id){
		
		$rc = M('VideoClassify')->where('id = %d',$id)->save(array('status'=>'-1'));
		return $rc;
	}
	
	//分类修改
	public function do_save($id,$data){
		
		$rc = M('VideoClassify')->where('id = %d',$id)->save($data);
		return $rc;
	}
	
	
	//查询单条分类信息
	public function do_find($id){
		
		$rc = M('VideoClassify')->where('id = %d and status != -1',$id)->find();
		return $rc;
		
	}
	
	
	
}